<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"  xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" >
<head  th:include="/include/commonHeader::commonHeader('不在位信息')">
</head>
<body class="gray-bg layer-blue">
    <div class="wrapper wrapper-content animated fadeInRight full-container">
        <div class="row" id="container">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <div class="btn-group table-tool" id="exampleToolbar" role="group">
                        <input id="query_pcode" type="text" class="table-tool-btn pull-left text-center"
                               placeholder="姓名"/>
                        <input type="text" placeholder="不在位日期"
                               class="table-tool-btn pull-left text-center" id="startDate"/>
                        <button type="button" class="btn btn-outline btn-success btn-refresh" data-toggle="tooltip"
                                title="查询" id="btn-search">
                            <i class="fa fa-search" aria-hidden="true"></i>
                        </button>
                        <shiro:hasPermission1 name="crewlocation:crewAbsent:add"></shiro:hasPermission1>
                            <button type="button" onclick="add()" class="btn btn-outline btn-success"
                                    data-toggle="tooltip" title="添加">
                                <i class="fa fa-plus" aria-hidden="true"></i>
                            </button>
                        <button type="button" onclick="reload()" class="btn btn-outline btn-success "
                                data-toggle="tooltip" title="刷新">
                            <i class="fa fa-refresh" aria-hidden="true"></i>
                        </button>
                    </div>
                    <table id="exampleTable" data-classes="table table-hover table-condensed">
                    </table>
                </div>
            </div>
        </div>
    </div>
<script type="text/javascript">
    var p_delete = 'hidden';
    var p_edit = 'hidden';
</script>
<shiro:hasPermission1 name="crewlocation:crewAbsent:delete"></shiro:hasPermission1>
<script type="text/javascript">
    p_delete = '';
</script>

<shiro:hasPermission1 name="crewlocation:crewAbsent:edit"></shiro:hasPermission1>
<script type="text/javascript">
    p_edit = '';
</script>


    <!-- 自定义js -->
    <script th:inline="javascript">
        var prefix = "/crewAbsent";
        var moduleFlag = [[${moduleFlag}]];
        $(function () {
            load();
            $("#btn-search").click(function(){
                $("#exampleTable").bootstrapTable('refresh');
            });

            $("#startDate").datetimepicker({
                minView: "month",
                language: 'zh-CN',
                format: 'yyyy-mm-dd',
                autoclose: true,
                todayBtn: true,
                todayHighlight: true,
                pickerPosition: "bottom-right"
            });
        });

        function load() {

	        $('#exampleTable').bootstrapTable(
					    {
						    method : 'post',
						    url : prefix + "/list.do",
						    iconSize : 'outline',
						    toolbar : '#exampleToolbar',
                            striped : true,
                            dataType : "json",
                            pagination : true,
                            clickToSelect : true,
                            pageSize : 10,
                            pageNumber : 1,
                            showColumns : false,
                            sidePagination : "server",
                            contentType : "application/x-www-form-urlencoded",
                            queryParams : function(params) {
                                return {
                                    pCode:$("#query_pcode").val(),
                                    fromDate:$("#startDate").val(),
                                    moduleFlag: moduleFlag,
                                    limit: params.limit,
                                    offset:params.offset
                                };
                            },
                            onDblClickRow : function(row, $element, field){
								view(row.id);
							},
                            columns : [
                                {
                                    field: 'idx',
                                    formatter: orderFormatter,
                                    title: '序号',
                                    align: 'center',
                                    width: '40'
                                },
                                    {
                                        field : 'name',
                                        title : '姓名'
                                    },
                                    {
                                        field : 'fromDate',
                                        title : '开始时间'
                                    },
                                    {
                                        field : 'toDate',
                                        title : '结束时间'
                                    },
                                    {
                                        field : 'absentType',
                                        title : '不在位类型'
                                    },
                                    {
                                        field : 'absentReason',
                                        title : '原因'
                                    },
                                    {
                                        field : 'operator',
                                        title : '修改人'
                                    },
                                    {
                                        field : 'opDate',
                                        title : '修改日期'
                                    },
                                    {
                                        title : '操作',
                                        align : 'center',
                                        visible : isShowOperation(),
                                        formatter:function(value,row,index){
                                            return [
                                                '<a class="' + p_edit + '" href="#" title="编辑" onclick="edit(' + row.id + ')">',
                                                '<i class="glyphicon glyphicon-edit"></i>',
                                                '</a>&nbsp;&nbsp;',
                                                '<a class="' + p_delete + '" href="#" title="删除" onclick="remove(' + row.id + ')">',
                                                '<i class="glyphicon glyphicon-remove  text-danger"></i>',
                                                '</a>&nbsp;&nbsp;'
                                            ].join('');
                                        }
                                    } ]
                        })

            $("#startDate").datetimepicker({
                minView: "month",
                language: 'zh-CN',
                format: 'yyyy-mm-dd',
                autoclose: true,
                todayBtn: true,
                todayHighlight: true,
                pickerPosition: "bottom-right"
            });
        }

        //是否有权限显示 '操作' 列
        function isShowOperation(){
            return (p_edit != 'hidden' || p_delete != 'hidden');
        }

        //刷新
        function reload(){
            $("#query_pcode").val("");
            $("#startDate").val("");
            $("#exampleTable").bootstrapTable('refresh');
        }

        //增加
        function add() {
            layer.open({
                type : 2,
                title : '新增',
                maxmin : true,
                shadeClose : false, // 点击遮罩关闭层
                area : [ '40%', '70%' ],
                content : prefix + '/add.do?moduleFlag=' + moduleFlag
            });
        }

        //编辑
        function edit(id) {
            layer.open({
                type : 2,
                title : '编辑',
                maxmin : true,
                shadeClose : false, // 点击遮罩关闭层
                area : [ '40%', '70%' ],
                content : prefix + '/edit.do?id=' + id
            });
        }

        //查看
        function view(id) {
            layer.open({
                type : 2,
                title : '查看',
                maxmin : true,
                shadeClose : false, // 点击遮罩关闭层
                area : [ '40%', '70%' ],
                content : prefix + '/view.do?id=' + id
            });
        }

        //删除
        function remove(id) {
            layer.confirm('确定要删除选中的记录？', {
                btn : [ '确定', '取消' ]
            }, function() {
                $.ajax({
                    url : prefix+"/delete.do",
                    type : "post",
                    data : {
                        'id' : id
                    },
                    success : function(r) {
                        if (r.code==0) {
                            layer.msg(r.msg);
                            reload();
                        }else{
                            layer.msg(r.msg);
                        }
                    }
                });
            })
        }

</script>
</body>
</html>